//package mutsumimod.savedata;
//
//import com.evacipated.cardcrawl.modthespire.lib.*;
//import com.google.gson.Gson;
//import com.google.gson.GsonBuilder;
//import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
//import com.megacrit.cardcrawl.saveAndContinue.SaveAndContinue;
//import com.megacrit.cardcrawl.saveAndContinue.SaveFile;
//import javassist.CtBehavior;
//import mutsumimod.cards.custom.Weltanschauung;
//import org.apache.logging.log4j.LogManager;
//import org.apache.logging.log4j.Logger;
//
//import java.util.HashMap;
//
//public class SaveData {
//    private static Logger logger = LogManager.getLogger("MutsumiSaveData");
//    public static final String KEY_PLAYER_HP = "PLAYER_HP";
//    public static final String KEY_PLAYER_STAND = "PLAYER_STAND";
//    private static int playerHp = 0;
//    private static int playerStand = 0;
//
//    public class MutsumiSaveData {
//        public int PLAYER_HP = 0;
//        public int PLAYER_STAND = 0;
//    }
//
//    @SpirePatch(clz = SaveFile.class, method = SpirePatch.CONSTRUCTOR, paramtypez = {SaveFile.SaveType.class})
//    public static class SaveTheSaveData {
//        @SpirePostfixPatch
//        public static void saveAllTheSaveData(SaveFile __instance, SaveFile.SaveType type) {
//            // Weltanschauung
//            SaveData.playerHp = Weltanschauung.playerHp;
//            SaveData.playerStand = Weltanschauung.playerStand;
//            SaveData.logger.info("Saved Mutsumi data");
//        }
//    }
//
//    @SpirePatch(clz = SaveAndContinue.class, method = "save", paramtypez = {SaveFile.class})
//    public static class SaveDataToFile {
//        @SpireInsertPatch(locator = Locator.class, localvars = {"params"})
//        public static void addCustomSaveData(SaveFile save, HashMap<Object, Object> params) {
//            params.put(SaveData.KEY_PLAYER_HP, SaveData.playerHp);
//            params.put(SaveData.KEY_PLAYER_STAND, SaveData.playerStand);
//        }
//
//        private static class Locator extends SpireInsertLocator {
//            public int[] Locate(CtBehavior ctMethodToPatch) throws Exception {
//                Matcher.MethodCallMatcher methodCallMatcher = new Matcher.MethodCallMatcher(GsonBuilder.class, "create");
//                return LineFinder.findInOrder(ctMethodToPatch, (Matcher)methodCallMatcher);
//            }
//        }
//    }
//
//    @SpirePatch(clz = SaveAndContinue.class, method = "loadSaveFile", paramtypez = {String.class})
//    public static class LoadDataFromFile {
//        @SpireInsertPatch(locator = Locator.class, localvars = {"gson", "savestr"})
//        public static void loadCustomSaveData(String path, Gson gson, String savestr) {
//            try {
//                MutsumiSaveData data = gson.fromJson(savestr, MutsumiSaveData.class);
//                SaveData.playerHp = data.PLAYER_HP;
//                SaveData.playerStand = data.PLAYER_STAND;
//                SaveData.logger.info("Loaded Mutsumi save data successfully.");
//            } catch (Exception e) {
//                SaveData.logger.error("Failed to load Mutsumi save data.");
//                e.printStackTrace();
//            }
//        }
//
//        private static class Locator extends SpireInsertLocator {
//            public int[] Locate(CtBehavior ctMethodToPatch) throws Exception {
//                Matcher.MethodCallMatcher methodCallMatcher = new Matcher.MethodCallMatcher(Gson.class, "fromJson");
//                return LineFinder.findInOrder(ctMethodToPatch, (Matcher) methodCallMatcher);
//            }
//        }
//    }
//
//    @SpirePatch(clz = AbstractDungeon.class, method = "loadSave")
//    public static class LoadSave {
//        @SpirePostfixPatch
//        public static void LoadCETSave(AbstractDungeon __instance, SaveFile file) {
//            // Weltanschauung
//            Weltanschauung.playerHp = SaveData.playerHp;
//            Weltanschauung.playerStand = SaveData.playerStand;
//            SaveData.logger.info("Save loaded.");
//        }
//    }
//}